<template>
	<view class="address">
	
		<view class="main">
			<radio-group @change="radioChange">
			<label class="list" v-for="(item, index) in initData" :key="index">
				
				<view><radio :value="item.id" :checked="index === current" /></view>
				<view class="right">
					<p class="name" >
						<text>{{item.contactUser}}</text> {{item.contactPhone}}
					</p>
					<view class="msg">
						
						<view class="text">
							{{item.province}} {{item.city}} {{item.region}} {{item.addrDetail}}
						</view>
						
					</view>
				</view>
				
			</label>
			</radio-group>
			<view v-if="initData.length==0" class="notavailable">
				<image src="../../../static/img/notavailable.png" mode="widthFix"></image>
				<view class="nottext">您还没有地址，快去下单吧</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	import {
		uniIcons
	} from '@dcloudio/uni-ui';
	import particulars from '../../../servers/agent/placeorder/particulars.js';
	export default {
		components: {
			uniIcons
		},
		data() {
			return {
				initData: [],
				phone:'',
				current: ''
			}
		},
		onLoad(option) {
			this.phone=option.phone;
		},
		onShow() {
			this.getDate();
		},
		mounted() {
			
		},
		methods: {
			getDate() {
			
				this.initData = []; //数据清空
				particulars.bindSearch(this.phone).then(res => {
					if(res.data){
						uni.hideLoading();
						this.initData=res.data;
						// this.receivename=res.data.agentName;
						// if(res.data.province||res.data.city||res.data.city){
						// 	this.resultInfo.result=`${res.data.province} ${res.data.city} ${res.data.city}`;
						// }
						// if(res.data.addr){
						// 	this.receiveaddress=res.data.addr;
						// }
						
						
					}
							
					})
					.catch(err => {
						console.log(err)
						console.log(new Error('请检查网络后重试'));
					});
			},
			 radioChange(evt) {
			            for (let i = 0; i < this.initData.length; i++) {
			                if (this.initData[i].id == evt.detail.value) {
			                    this.current = i;
								uni.$emit('checkedAddress', this.initData[i])
								uni.navigateBack({
									delta:1
								})
			                    break;
			                }
			            }
			        },
			// checked(e) {
			// 	if (this.is_order) {
			// 		uni.$emit('checkedAddress', e)
			// 		this.commonality.back()
			// 	}
			// },
			
			

			
		}
	}
</script>

<style scoped lang="scss" rel="stylesheet/scss">
	.none{
		height: 30vh;
	}
	.address {
		
	
		.main {
		
			background: #fff;
	
			.list {
				padding: 20rpx;
				border-bottom: 1rpx solid #eeeeee;
				display: flex;
				align-items: center;
				.right{
					margin-left: 20rpx;
				}
				.name {
					font-size: 28rpx;
					margin-bottom: 25rpx;
	
					text {
						margin-right: 40rpx;
					}
				}
	
				.msg {
					display: flex;
	
					
	
					.text {
						flex: 1;
						font-size: 26rpx;
						color: #666666;
					}
	
					
				}
			}
	
			
		}
	}
</style>
